#include <iostream>
#include <fstream>

using namespace std;

void test01() // test C++ binary write and read
{
    ofstream of;
    of.open("t1.bin", ios::binary | ios::out);
    double d[] = {1.0, 2.1, 3.2};
    double *p1 = d;
    for (size_t i = 0; i < 3; i++)
    {
        of.write((char *)p1, sizeof(d[0]));
        p1++;
    }

    of.close();

    ifstream of1;

    of1.open("t1.bin", ios::binary | ios::in);
    double r[3] = {0.0};
    double *p2 = r;
    for (size_t i = 0; i < 3; i++)
    {
        of1.read((char *)p2, sizeof(r[0]));
        cout << *p2 << endl;
        p2++;
    }
    of1.close();
}


int main()
{
    test01();
    return 0;
}